import requests
from bs4 import BeautifulSoup

# URL of the webpage containing the buttons
url = "https://www.aigei.com/sound/class/is_vip_false?sub=gou_jiao_sheng_3#resContainer"
headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'
}
# Send an HTTP GET request to the webpage
response = requests.get(url,headers=headers)
print(response.text)

# Parse the HTML content of the webpage
soup = BeautifulSoup(response.text, "html.parser")

# Find all elements with the specified class
buttons = soup.find_all("a", {"class": "audio-down-btn"})

# Loop through each button
for button in buttons:
    # Extract the href attribute of the button
    download_link = button.get("href")

    # Check if the download link is not empty
    if download_link:
        # Send an HTTP GET request to download the content
        content_response = requests.get(download_link)

        # Save the content to a file
        print(content_response.text)

        print(f"Content {buttons.index(button) + 1} downloaded successfully.")
    else:
        print("Download link not found for one of the buttons.")
